//
//  DYZCustomTerritoryController.m
//  DYZCars
//
//  Created by 白白龙腾 on 16/8/20.
//  Copyright © 2016年 MF. All rights reserved.
//

#import "DYZCustomTerritoryController.h"
static NSString *customTerritoryCellid = @"customTerritoryCellid";
@interface DYZCustomTerritoryController ()

@end

@implementation DYZCustomTerritoryController

- (void)viewDidLoad {
    [super viewDidLoad];
    //禁用弹性效果
    self.tableView.bounces = NO;
    //隐藏没有内容的cell的下划线
    self.tableView.tableFooterView = [[UIView alloc]init];
    
    UIButton *leftBtn = [[UIButton alloc]init];
    [leftBtn setImage:[UIImage imageNamed:@"back"] forState:UIControlStateNormal];
    [leftBtn sizeToFit];
    UIBarButtonItem *item = [[UIBarButtonItem alloc]initWithCustomView:leftBtn];
    self.navigationItem.leftBarButtonItem = item;
    [leftBtn addTarget:self action:@selector(aButtonClick) forControlEvents:UIControlEventTouchUpInside];

    //设置navitem的文字
    UILabel *customLab = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 100, 30)];
    [customLab setTextColor:[UIColor blackColor]];
    [customLab setText:@"自定义区域"];
    customLab.font = [UIFont boldSystemFontOfSize:20];
    self.navigationItem.titleView = customLab;
    
    UIButton *rightBtn = [[UIButton alloc]init];
    [rightBtn setTitle:@"保存" forState:UIControlStateNormal];
    [rightBtn setTintColor:[UIColor whiteColor]];
    [rightBtn sizeToFit];
    UIBarButtonItem *rightItem = [[UIBarButtonItem alloc]initWithCustomView:rightBtn];
    self.navigationItem.rightBarButtonItem = rightItem;
    [rightBtn addTarget:self action:@selector(rightButtonClick) forControlEvents:UIControlEventTouchUpInside];
    
    //注册单元格
    [self.tableView registerNib:[UINib nibWithNibName:@"DYZCustomTerritoryCell" bundle:nil] forCellReuseIdentifier:customTerritoryCellid];
}

//点击aButton
- (void)aButtonClick{
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)rightButtonClick{
    [self.navigationController popToViewController:[self.navigationController.viewControllers objectAtIndex:1] animated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Table view data source

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 1;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:customTerritoryCellid forIndexPath:indexPath];
    
    return cell;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 64;
}

@end
